package br.mg.bhe.ftpobre.command;

import br.mg.bhe.ftpobre.Main;
import br.mg.bhe.ftpobre.gui.MainFrame;
import br.mg.bhe.ftpobre.gui.fs.FileTableModelBuilder;

/**
 * 
 * @author Aureliano
 */
public class RefreshLocalFilesViewCommand implements ICommand {

	@Override
	public void execute() {
		if (this.canExecute()) {
			this.doAction();
		}
	}

	@Override
	public boolean canExecute() {
		return Main.getConnectionData().isConnected();
	}

	private void doAction() {
		String path = MainFrame.getInstance().getAbsolutePathFromLocalFilePath();
		MainFrame.getInstance().getTableLocalFiles().setModel(
				FileTableModelBuilder.createLocalFilesTableModel(path));
	}
}